Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webpack-sources

Package Overview
Dependencies
Maintainers
5
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-sources

Source code handling classes for webpack

  • 1.4.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created

What is webpack-sources?

The webpack-sources package provides utility functions to manage source code and SourceMap data for webpack. It allows manipulation of the source code of modules and the generation of SourceMaps for better debugging support.

What are webpack-sources's main functionalities?

RawSource

RawSource is used to represent source code that does not need a SourceMap because it's not transformed.

const { RawSource } = require('webpack-sources');
const source = new RawSource('const a = 1;');
console.log(source.source());

SourceMapSource

SourceMapSource is used when the source code has an associated SourceMap. It is useful for preserving source maps through transformations.

const { SourceMapSource } = require('webpack-sources');
const source = new SourceMapSource('const a = 1;', 'file.js', '{"version":3,"sources":["file.js"],"names":["a"],"mappings":"AAAA,MAAM,IAAI"}');
console.log(source.sourceAndMap());

OriginalSource

OriginalSource is used for representing original source code that will be transformed. It generates a SourceMap for the original code.

const { OriginalSource } = require('webpack-sources');
const source = new OriginalSource('const a = 1;', 'file.js');
console.log(source.source());

ReplaceSource

ReplaceSource allows modifications to the source code, such as replacing certain parts of it, while keeping track of changes for SourceMap generation.

const { ReplaceSource, OriginalSource } = require('webpack-sources');
const originalSource = new OriginalSource('const a = 1;', 'file.js');
const replaceSource = new ReplaceSource(originalSource);
replaceSource.replace(0, 10, 'const b = 2;');
console.log(replaceSource.source());

ConcatSource

ConcatSource is used to concatenate multiple sources into a single source. It is useful for combining multiple assets into one.

const { ConcatSource, RawSource } = require('webpack-sources');
const source1 = new RawSource('const a = 1;');
const source2 = new RawSource('\nconst b = 2;');
const concatenatedSource = new ConcatSource(source1, source2);
console.log(concatenatedSource.source());

Other packages similar to webpack-sources

Keywords

FAQs

Package last updated on 05 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc